/*
 * SubSonic - http://subsonicproject.com
 * 
 * The contents of this file are subject to the Mozilla Public
 * License Version 1.1 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of
 * the License at http://www.mozilla.org/MPL/
 * 
 * Software distributed under the License is distributed on an 
 * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * rights and limitations under the License.
*/

using System.Collections.Generic;

namespace SubSonic.QueryEngine
{
    /// <summary>
    /// Summary for the SqlParser class
    /// </summary>
    public abstract class SqlParser
    {
        /// <summary>
        /// Selects the template.
        /// </summary>
        /// <returns></returns>
        public abstract string SelectTemplate();

        /// <summary>
        /// Gets the select.
        /// </summary>
        /// <param name="topQualifier">The top qualifier.</param>
        /// <param name="columnList">The column list.</param>
        /// <param name="table">The table.</param>
        /// <returns></returns>
        public abstract string GetSelect(string topQualifier, string columnList, TableSchema.Table table);

        /// <summary>
        /// Gets the select.
        /// </summary>
        /// <param name="table">The table.</param>
        /// <returns></returns>
        public abstract string GetSelect(TableSchema.Table table);

        /// <summary>
        /// Gets the join.
        /// </summary>
        /// <param name="joinType">Type of the join.</param>
        /// <param name="table1">The table1.</param>
        /// <param name="table2">The table2.</param>
        /// <returns></returns>
        public abstract string GetJoin(JoinType joinType, TableSchema.Table table1, TableSchema.Table table2);

        /// <summary>
        /// Gets the join.
        /// </summary>
        /// <param name="table1">The table1.</param>
        /// <param name="table2">The table2.</param>
        /// <returns></returns>
        public abstract string GetJoin(TableSchema.Table table1, TableSchema.Table table2);

        /// <summary>
        /// Gets the join.
        /// </summary>
        /// <param name="joinType">Type of the join.</param>
        /// <param name="table1">The table1.</param>
        /// <param name="column1">The column1.</param>
        /// <param name="table2">The table2.</param>
        /// <param name="column2">The column2.</param>
        /// <returns></returns>
        public abstract string GetJoin(JoinType joinType, TableSchema.Table table1, TableSchema.TableColumn column1, TableSchema.Table table2, TableSchema.TableColumn column2);

        /// <summary>
        /// Gets the where.
        /// </summary>
        /// <param name="columnName">Name of the column.</param>
        /// <param name="comp">The comp.</param>
        /// <param name="value">The value.</param>
        /// <returns></returns>
        public abstract string GetWhere(string columnName, Comparison comp, object value);

        /// <summary>
        /// Gets the and.
        /// </summary>
        /// <param name="columnName">Name of the column.</param>
        /// <param name="comp">The comp.</param>
        /// <param name="value">The value.</param>
        /// <returns></returns>
        public abstract string GetAnd(string columnName, Comparison comp, object value);

        /// <summary>
        /// Gets the or.
        /// </summary>
        /// <param name="columnName">Name of the column.</param>
        /// <param name="comp">The comp.</param>
        /// <param name="value">The value.</param>
        /// <returns></returns>
        public abstract string GetOr(string columnName, Comparison comp, object value);


        #region Insert

        /// <summary>
        /// Gets the insert select.
        /// </summary>
        /// <param name="to">To.</param>
        /// <param name="listTo">The list to.</param>
        /// <param name="from">From.</param>
        /// <param name="listFrom">The list from.</param>
        /// <returns></returns>
        public abstract string GetInsertSelect(TableSchema.Table to, string listTo, TableSchema.Table from, string listFrom);

        /// <summary>
        /// Gets the insert values.
        /// </summary>
        /// <param name="to">To.</param>
        /// <param name="columns">The columns.</param>
        /// <returns></returns>
        public abstract string GetInsertValues(TableSchema.Table to, List<string> columns);

        #endregion

        #region Update

        /// <summary>
        /// Gets the update.
        /// </summary>
        /// <param name="to">To.</param>
        /// <param name="columns">The columns.</param>
        /// <returns></returns>
        public abstract string GetUpdate(TableSchema.Table to, List<string> columns);

        #endregion


        #region Delete

        /// <summary>
        /// Gets the delete.
        /// </summary>
        /// <param name="tbl">The TBL.</param>
        /// <returns></returns>
        public abstract string GetDelete(TableSchema.Table tbl);

        #endregion


        #region Grouping

        /// <summary>
        /// Opens the paren.
        /// </summary>
        /// <returns></returns>
        public string OpenParen()
        {
            return "(";
        }

        /// <summary>
        /// Closes the paren.
        /// </summary>
        /// <returns></returns>
        public string CloseParen()
        {
            return ")";
        }

        #endregion
    }
}